﻿using EFCore.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SIService;
using SService;

namespace WMSWeb.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SalesreturnController : ControllerBase
    {
        private readonly WmssystemContext myDb;
        private readonly SalesreturnS salesreturnS;

        public SalesreturnController(WmssystemContext myDb, SService.SalesreturnS salesreturnS)
        {
            this.myDb = myDb;
            this.salesreturnS = salesreturnS;
        }
        /// <summary>
        /// 4个条件分页查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PO_Salesreturn>> Fye(int pageSize, int currentPage, string Number = null, string Status = null, string Supplier = null, DateTime? date = null, DateTime? date1 = null)
        {
            return await salesreturnS.Fye(pageSize, currentPage, Number, Status, Supplier, date, date1);
        }
        [HttpGet]
        public async Task<List<PO_Salesreturn>> Qu()
        {
            return await salesreturnS.Qu();
        }
        /// <summary>
        /// 销售退货明细添加
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<int> Add(PO_Salesreturndetails pO_Purchasereturndetail)
        {
            return await salesreturnS.Add(pO_Purchasereturndetail);
        }
        /// <summary>
        /// 销售退货添加
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<int> Add1(PO_Salesreturn pO_Salesreturn)
        {
            return await salesreturnS.Add1(pO_Salesreturn);
        }
        /// <summary>
        /// 销售退货批量删除
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpDelete]
        public async Task<int> XsDel(List<int> Ids)
        {
            return await salesreturnS.XsDel(Ids);
        }
        /// <summary>
        /// 销售退货审核
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPut]
        public async Task<int> XsShen(PO_Salesreturn pO_Purchasereturn, string to)
        {
            return await salesreturnS.XsShen(pO_Purchasereturn, to);
        }
    }
}
